<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <!--首页内容-->
    <script>$('.blog-nav-item-home').addClass('active');</script>
    <div class="col-sm-8 blog-main">
        <h2>欢迎</h2>
        <div class="col-sm-6 well newest-post newest-post-text">
            <h:link outcome="article" value="查看所有文章" styleClass="btn btn-default"/>
            <hr/>
            <h3>最新文章：</h3>
            <c:choose>
                <c:when test="#{postBean.newestText != null}">
                    <div class="blog-post">
                        <h4 class="blog-post-title">
                            <h:link outcome="/article?id=#{postBean.newestText.id}"
                                    value="#{postBean.newestText.title}"/>
                        </h4>
                        <div class="blog-post-meta">
                            作者：<span class="blog-post-author">#{postBean.newestText.author.username}</span>
                            发表时间：<span class="blog-post-publish-date">#{postBean.newestText.publishDate}</span>
                            分类：<span class="blog-post-publish-category">#{postBean.newestText.category.name}</span>
                        </div>
                        <div class="blog-post-content">
                            <c:choose>
                                <c:when test="#{postBean.newestText.content.length() lt 200}">
                                    <h:outputText escape="false" value="#{postBean.newestText.content}"/>
                                </c:when>
                                <c:otherwise>
                                    <h:outputText escape="false"
                                                  value="#{postBean.newestText.content.substring(0,200)}"/>
                                </c:otherwise>
                            </c:choose>
                        </div>
                    </div>
                </c:when>
                <c:otherwise>
                    暂无文章
                </c:otherwise>
            </c:choose>
        </div>
        <div class="col-sm-6 well  newest-post newest-post-image">
            <h:link outcome="photo" value="查看所有照片" styleClass="btn btn-default"/>
            <hr/>
            <h3>最新照片：</h3>
            <c:choose>
                <c:when test="#{postBean.newestImage !=null}">
                    <div class="blog-post">
                        <h4 class="blog-post-title">
                            <h:link outcome="/article?id=#{postBean.newestImage.id}"
                                    value="#{postBean.newestImage.title}"/>
                        </h4>
                        <div class="blog-post-meta">
                            作者：<span class="blog-post-author">#{postBean.newestImage.author.username}</span>
                            发表时间：<span class="blog-post-publish-date">#{postBean.newestImage.publishDate}</span>
                            分类：<span class="blog-post-publish-category">#{postBean.newestImage.category.name}</span>
                        </div>
                        <div class="blog-post-content">
                            <h:graphicImage alt="照片" url="#{postBean.newestImage.content}"/>
                        </div>
                    </div>
                </c:when>
                <c:otherwise>
                    暂无照片
                </c:otherwise>
            </c:choose>
        </div>
    </div>
</ui:composition>
